home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / ShiftRGB.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.7 KB  |  140 lines

  1. /*
  2. ** $VER: ShiftRGB.ieb 2.0, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten 
  5. ** 18/1 1997 Stockholm/Sweden
  6. **
  7. ** Swaps/copies brightness data in the R, G and B channels.
  8. ** Based on the IE script ShiftRGB.rexx 3.0.
  9. */
  10.  
  11. options results
  12. signal on error
  13.  
  14. parse arg input command
  15. input = upper(strip(input))
  16. address 'IMAGEENGINEER'
  17.  
  18. select  /* Required batch script commands */
  19.   when input = 'INFO' then    return get_info()
  20.   when input = 'CONFIG' then  return get_config(command)
  21.   when input = 'PROCESS' then return process_image(command)
  22.   otherwise do
  23.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  24.     return '<ERROR>'
  25.   end
  26. end
  27.  
  28. exit 0
  29.  
  30. /* Required "Get_info" procedure  ------------------------------------ */
  31. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  32.  
  33. get_info:
  34.   back = 'OK'
  35. return back
  36.  
  37. /* Required "Get_config" procedure  ---------------------------------- */
  38.  
  39. get_config:
  40.   parse arg '"'command'"'
  41.  
  42.   'IE_TO_FRONT'
  43.  
  44.   if command = '' then do
  45.     'FORM "ShiftRGB" " Accept | Cancel "',
  46.     ' TEXT,"Swaps and/or copies brightness data between color channels."',
  47.     ' TEXT,"Red channel will inherit data from..."',
  48.     ' CYCLE,"Channel:","Red|Green|Blue",0',
  49.     ' TEXT,"Green channel will inherit data from..."',
  50.     ' CYCLE,"Channel:","Red|Green|Blue",1',
  51.     ' TEXT,"Blue channel will inherit data from..."',
  52.     ' CYCLE,"Channel:","Red|Green|Blue",2'
  53.  
  54.     parse var result ok Rd Gr Bl .
  55.     if ok = 0 then exit
  56.   end
  57.   else do
  58.     'REQUEST' '"This batch script does not have'd2c(10)'any settings for the last frame."' '" OK "'
  59.     Rd='none'; Gr='none'; Bl='none'
  60.   end
  61.   
  62.   back = '#'Rd '#'Gr '#'Bl
  63. return back
  64.  
  65. /* Required "Process_image" procedure  ------------------------------- */
  66.  
  67. process_image:
  68.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  69.   parse var options '#' c.0 '#' c.1 '#' c.2 .
  70.   
  71.   'OPEN' '"'src_image'"' '24'
  72.   if (RC ~= 0) then do
  73.     'IE_TO_FRONT'
  74.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  75.     return '<ERROR>'
  76.   end
  77.   else LoadImage = result
  78.  
  79.   MergeImage = ''
  80.   
  81.   do i = 0 to 2
  82.     if c.i = 0 then 'BRIGHTNESS' LoadImage '-255' 'GREEN BLUE'
  83.     if c.i = 1 then 'BRIGHTNESS' LoadImage '-255' 'RED BLUE'
  84.     if c.i = 2 then 'BRIGHTNESS' LoadImage '-255' 'RED GREEN'
  85.     Image = RESULT
  86.  
  87.     if (i*85-c.i*85) ~= 0 then do
  88.       'HUE' Image (i*85-c.i*85)
  89.       HueImage = RESULT
  90.       'CLOSE' Image
  91.     end
  92.     else HueImage = Image
  93.  
  94.     if MergeImage ~= '' then do
  95.       'MARK' HueImage 'PRIMARY'
  96.       'MARK' MergeImage 'SECONDARY'
  97.       'COMPOSITE' 0 0 'ADD'
  98.       Image = RESULT
  99.       'CLOSE' HueImage
  100.       'CLOSE' MergeImage
  101.       MergeImage = Image
  102.     end
  103.     else MergeImage = HueImage
  104.   end
  105.   
  106.   OutputImage = MergeImage
  107.   'CLOSE' LoadImage
  108.   
  109.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  110.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  111.   if (RC ~= 0) then do
  112.     'IE_TO_FRONT'
  113.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  114.     return '<ERROR>'
  115.   end
  116.   'CLOSE' OutputImage
  117.  
  118.   back = 'OK'
  119. return back
  120.  
  121. /* Internal procedures  ---------------------------------------------- */
  122.  
  123. /*******************************************************************/
  124. /* This is where control goes when an error code is returned by IE */
  125. /* It puts up a message saying what happened and on which line     */
  126. /*******************************************************************/
  127.  
  128. error:
  129. if RC=5 then do
  130.     IE_TO_FRONT
  131.     LAST_ERROR
  132.     'REQUEST "'||RESULT||'"'
  133. end
  134. else do
  135.     IE_TO_FRONT
  136.     LAST_ERROR
  137.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  138. end
  139. return '<ERROR>'
  140.